!!!
%html
  %head
    %meta{charset: "utf-8"}
    %meta{"http-equiv"=>"X-UA-Compatible", "content"=>"IE=edge"}
    %meta{"name"=>"viewport", "content"=>"width=device-width, initial-scale=1"}
    %title= blog_title
    = stylesheet_link_tag 'application', media: 'all'
    = javascript_include_tag 'application'
    = csrf_meta_tags

  %body
    .container.wrap_body
      %nav.navbar.navbar-default.navbar-fixed-top{role:'navigation'}
        .container.container-fluid
          .navbar-header
            = link_to blog_title, root_path, class: 'navbar-brand'
          .collspse.navbar-collapse.site-header
            %ul.nav.navbar-nav
              %li{class: "#{'active' if params[:controller] == 'articles' && params[:action] == 'index'}"}
                = link_to '文章列表', articles_path
              %li
                = link_to '关于博主', about_blogs_path
            %ul.nav.navbar-nav.navbar-right
              - if is_logined?
                %li.dropdown
                  .navbar-header.navbar-avatar
                    = avatar @current_user
                  = link_to '#', class: 'dropdown-toggle pull-right', "data-toggle"=>"dropdown" do
                    = @current_user.nickname
                    %span.caret
                  %ul.dropdown-menu{role: 'menu'}
                    %li
                      = link_to '#' do
                        = gravatar_image_tag @current_user.email, size: 100, alt: @current_user.nickname, gravatar: {default: 'http://www.gravatar.com/avatar/0c821f675f132d790b3f25e79da739a7'}
                    %li
                      = link_to '设置', set_blogs_path
                    - if current_user_is_admin?
                      %li
                        = link_to '写博客', new_article_path
                    %li
                      = link_to '退出', logout_path
              - else
                %ul.navbar-button.navbar-right
                  %li
                    = link_to '登录', login_path, class: 'btn btn-default'
                  %li
                    = link_to '注册', register_path, class: 'btn btn-primary'
            = form_tag articles_path, method: 'get', class: 'navbar-form pull-right', role: 'search', id: 'search_form' do
              .form-group
                = text_field_tag 'keyword', params[:keyword], class: 'form-control', placeholder: '请输入关键字'
                %a#search_button
                  %span.icon.icon-search
    .container.body_content
      = yield
      = render partial: 'layouts/footer'
:javascript
  $(function(){
    $('#search_button').click(function(){
      $('#search_form').submit();
    });
  });